package office.dao.person;

import platform.common.dao.impl.BaseDomainProviderImpl;

public class LeaveRequestDP extends BaseDomainProviderImpl  {
	
	public String getLeaveRequestForSum(){
		String hql = "from LeaveRequest where state >= ? " +
		"and " +
		"( beginDate >= ? and beginDate <= ? ) ";
		return hql;
	}
	
	/**
	 * 获取某用户提交的或需要自己审批的请假
	 * @return
	 */
	public String getFindByUserIdCheckRole(){
		return "select new office.action.person.form.LeaveRequestForm(a.id,a.beginDate,a.endDate," +
				"a.sumDay,a.reson,a.user.id,a.user.cname," +
				"a.entryRole,a.checkRole,a.entryDate," +
				"a.state) from "+this.getDomainClassName()+" a,User b where " +
				"(a.user.id=:userId or checkRole =:checkRole) and a.user.id = b.id  order by a.entryDate desc";
	}
	
	
	/**
	 * 获取某用户提交的或需要自己审批的请假(销售人员、区域经理、销售经理需要限制是和自己同一部门人提交审批的记录)
	 * @return
	 */
	public String getFindByUserIdCheckRoleDept(){
		return "select new office.action.person.form.LeaveRequestForm(a.id,a.beginDate,a.endDate," +
				"a.sumDay,a.reson,a.user.id,a.user.cname," +
				"a.entryRole,a.checkRole,a.entryDate," +
				"a.state) from "+this.getDomainClassName()+" a,User b where " +
				"(a.user.id=:userId or checkRole =:checkRole) and a.user.id = b.id  and b.department.id in (:deptId) order by a.entryDate desc";
	}
	
	public String getFindById(){
		return "select new office.action.person.form.LeaveRequestForm(a.id,a.beginDate,a.endDate," +
		"a.sumDay,a.reson,a.user.id,a.user.cname," +
		"a.entryRole,a.checkRole,a.entryDate," +
		"a.state) from "+this.getDomainClassName()+" a where " +
		" a.id=:id";
	}
	
}
